# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo08
# Description:
# Author:       98745
# Date:         2019/3/17
#-------------------------------------------------------------------------------

from urllib3 import *
from bs4 import BeautifulSoup
disable_warnings()
html='''
<html>
    <head><title>我的网页</title></head>
    <body attr='test' class='style1'>
        <a href='aa.html'>aa.html</a>
        <a href='bb.html' class='style1'>bb.html</a>
        <b>xyz</b>
    </body>
</html>
'''

soup=BeautifulSoup(html,'lxml')
from bs4 import NavigableString
# def find(tag):
#     if tag.has_attr('class'):
#         if 'style1' in tag['class']:
#             return True
#     else:
#         return False
#
# for tag in soup.find_all(find):
#     print(tag)
#     print('-------------')
print(len(soup.body))
print(len(soup.body.a))
print(len(soup.body.b))